Add the ability to implement a specific logic when a capacity is enabled #18454
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist before requesting a review
Description
It is based on #18306 and replaces it. It fixes #18304.
The purpose of this PR is to add a
CapacityInterface::onCapacityEnabled()
method that can be used to define a logic that has to be call only at the moment a capacity is enabled. For instance, the loading of the default import rules has to be done only once.I had to review a bit the custom assets/dropdowns definition handling to be able to reload a definition at runtime. This was already done in the tests with some kind of hacky code, but now it is done in a more proper way, and this is no longer necessary to use the reflection API to do this.
I also added a call to
CapacityInterface::onCapacityDisabled()
in theAssetDefinition::cleanDbOnPurge()
. It is probably unecessary for the most common cases, but it permits to be sure that the cleaning logic implemented by each capacity is executed when a definition is removed.